﻿Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.ApplicationBlocks.Data
Imports System.Configuration

Namespace DotNetNuke.Modules.ActiveForums.Data
    Public Class Connection
#Region "Private Members"
        Private _providerConfiguration As DotNetNuke.Framework.Providers.ProviderConfiguration = DotNetNuke.Framework.Providers.ProviderConfiguration.GetProviderConfiguration("data")
        Friend connectionString As String
        Friend objectQualifier As String
        Friend databaseOwner As String
        Friend databaseObjectPrefix As String = "activeforums_"
        Friend dbPrefix As String
#End Region
#Region "Constructors"
        Public Sub New()
            connectionString = ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString
            Dim objProvider As DotNetNuke.Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), DotNetNuke.Framework.Providers.Provider)

            objectQualifier = objProvider.Attributes("objectQualifier")
            If objectQualifier <> "" And objectQualifier.EndsWith("_") = False Then
                objectQualifier += "_"
            End If

            databaseOwner = objProvider.Attributes("databaseOwner")
            If databaseOwner <> "" And databaseOwner.EndsWith(".") = False Then
                databaseOwner += "."
            End If
            dbPrefix = databaseOwner & objectQualifier & databaseObjectPrefix
        End Sub
#End Region
    End Class
End Namespace

